package com.black.opsadmin.controller;

import com.black.opsadmin.service.RoleService;
import com.black.opscommon.entity.Role;
import com.black.opscommon.utils.R;
import com.black.opsoauth2.annotation.Inner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Set;


/**
 * @author qiang.zhang
 * @date 2018-11-23
 */
@RestController
@RequestMapping("api")
public class RoleController {

    @Autowired
    private RoleService roleService;


    /**
     * 获取指定用户角色信息by roleId
     *
     * @return 用户信息
     */
    @Inner
    @GetMapping("/roles/{roleId}")
    public R findByUsername(@PathVariable Long roleId) {


        Set<Role> roles = roleService.findByUsers_Id(roleId);

        return new R<>(roles);
    }

}
